package week03;

public class T021 {
	
	public static int shu(int n) {
		int sum=1;
		int sqr = (int) Math.sqrt(n);
		for(int i=2;i<=sqr;i++) {
			if(n%i==0) {
			if(i*i!=n) sum+=(i+n/i);
			else  sum+=i;}
		}
		return sum;
	}
	
	public static void run(int n) {
		int []a =new int[10000];
		int sum=0;
		for(int i=1;i<=n;i++) {
			if(shu(shu(i))==i&&i!=shu(i)&&a[i]!=-1) {
				sum+=(i+shu(i));
				a[i]=-1;
				a[shu(i)]=-1;
			}
		}
		System.out.println(sum);
	}
	
	
	public static void main(String[] args) {
		run(10000);
	}
	
	

}
